	<h2>Store: Edit store</h2>
	<?php echo validation_errors(); ?>
	<form id="storeForm"  action="<?=site_url(array("c" => "cms_store", "m" => "edit_store", "store_id" => $store['id']))?>" method="post">
		<input type="hidden" name="item_id" value="<?=$store['id']?>" />
		<table border="0" cellspacing="0" cellpadding="0" class="form-table" width="100%">
			<tr>
				<th>Title: </th>
				<td><input type="text" name="item_title" class="input-text required" value="<?=$store['title']?>"></td>
			</tr>
			<tr>
				<th>Store Name: </th>
				<td><input type="text" name="item_company_name" class="input-text required" value="<?=$store['company_name']?>"></td>
			</tr>
			<tr>
				<th>Image: </th>
				<td>
					<input type="text" id="item_image" name="item_image" value="<?=$store['image']?>">
					<input id="item_image_btn" name="item_image_btn" type="button" class="ins" value="..." />
					<?php if(!empty($store['image'])):?>
					<img src="<?=$store['image']?>" width="30"/>
					<?php endif;?>
				</td>
			</tr>
			<tr>
				<th>Gallery: </th>
				<td>
					<select name="item_gallery_id">
						<option value="">Please select</option>
						<?php foreach($galleries as $item):?>
						<?php 
							$selected = $item['id'] == $store['gallery_id'] ? "selected='true'":"";
						?>
						<option value="<?=$item['id']?>" <?=$selected?>>
							<?=$item['title']?>
						</option>
						<?php endforeach;?>
					</select>
				</td>
			</tr>
			<tr>
				<th>Website: </th>
				<td><input type="text" name="item_website" class="input-text required website" value="<?=$store['website']?>"></td>
			</tr>
			<tr>
				<th>Email: </th>
				<td><input type="text" name="item_email" class="input-text required email" value="<?=$store['email']?>"></td>
			</tr>
			<tr>
				<th>Zipcode: </th>
				<td><input type="text" name="item_zipcode" class="input-text required number" value="<?=$store['zipcode']?>"></td>
			</tr>
			<tr>
				<th>Phone: </th>
				<td><input type="text" name="item_home_phone" class="input-text" value="<?=$store['home_phone']?>"></td>
			</tr>
			<tr>
				<th>City: </th>
				<td><input type="text" name="item_city" class="input-text" value="<?=$store['city']?>"></td>
			</tr>
			<tr>
				<th>State: </th>
				<td><input type="text" name="item_state" class="input-text" value="<?=$store['state']?>"></td>
			</tr>
			<tr>
				<th>Address: </th>
				<td><input type="text" name="item_address" class="input-text" value="<?=$store['address']?>"></td>
			</tr>
			<tr>
				<th>Types: </th>
				<td>
					<select name="item_types[]" class="input-text" multiple="true" size="4">
						<option value="">Please select</option>
						<?php foreach($types as $type):?>
						<?php 
							$selected = '';
							if(is_array($type_selected)){
								$selected = array_search($type['id'], $type_selected) !== FALSE ? "selected='true'":"";
							}
						?>
						<option value="<?=$type['id']?>" <?=$selected?>>
							<?=$type['title']?>
						</option>
						<?php endforeach;?>
					</select>
				</td>
			</tr>
			<tr>
				<th>Business hour: </th>
				<td>
					<?=$this->ckeditor->editor("item_business_hour", $store['business_hour'], array("baseHref" => site_url()));?>
				</td>
			</tr>
			<tr>
				<th>Description: </th>
				<td>
					<?=$this->ckeditor->editor("item_desc", $store['desc'], array("baseHref" => site_url()));?>
				</td>
			</tr>
			<tr>
				<th>Coupons: </th>
				<td>
					<?=$this->ckeditor->editor("item_coupon", $store['coupon'], array("baseHref" => site_url()));?>
				</td>
			</tr>
			<tr>
				<th>Menu: </th>
				<td>
					<?=$this->ckeditor->editor("item_menu", $store['menu'], array("baseHref" => site_url()));?>
				</td>
			</tr>
			<tr>
				<th>Is Special: </th>
				<td>
					Yes <input type="radio" name="item_is_special" class="" <?='yes'==$store['is_special'] ? 'checked="true"':''?> value="yes"/>
					No <input type="radio" name="item_is_special" class=""  <?='no'==$store['is_special'] ? 'checked="true"':''?> value="no"/>
				</td>
			</tr>
			<tr>
				<th>Google map: </th>
				<td>
					<textarea name="item_google_map" class="input-textarea-medium" cols="28" rows="5"><?=$store['google_map']?></textarea>
				</td>
			</tr>
			<tr>
				<th>&nbsp;</th>
				<td>
					<input type="button" class="ins" onClick="javascript:history.back();" value="Cancel" />
					<input name="Submit" type="submit" class="ins" value="Save" />
				</td>
			</tr>
		</table>
	</form>
<script type="text/javascript">
	var finder = new CKFinder();
	finder.BasePath = '/system/plugins/ckfinder/';
	finder.SelectFunction = SetFileFieldNewImg;
	$("#item_image_btn").bind("click", function(){
		finder.Popup();
	});
	function SetFileFieldNewImg(fileUrl) {
		$('#item_image').val(fileUrl);
	}
</script>